<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="UTF-8" />
        <link rel="stylesheet" href="styles/style.css">
        <link rel="stylesheet" href="styles/theme/atom-one-dark.css">
        <title>例子44-ES6/7常用语法介绍</title>
    </head>

    <body>
        <pre>
            <code>
                // 例子44

                class Person {
                    constructor(name, age) {
                        this.name = name;
                        this.age = age;
                    }

                    getName() {
                        return this.name;
                    }

                    static getAge() {
                        return 'It\'s a secret';
                    }
                }

                class Student extends Person {

                }

                let p = new Person('Tom', '18');
                console.log(Person.getAge());  // "It's a secret"
                console.log(Student.getAge()); // "It's a secret"
                p.getAge(); // Uncaught TypeError: p.getAge is not a function
            </code>
        </pre>
        <script src="scripts/libs/highlight.pack.js"></script>
        <script src="scripts/44.js"></script>
        <script>
            hljs.initHighlightingOnLoad();
        </script>
    </body>

</html>